﻿//http://en.wikipedia.org/wiki/XMLHttpRequest
if (typeof XMLHttpRequest == "undefined")
    XMLHttpRequest = function () {
        try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); }
        catch (e) { }
        try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); }
        catch (e) { }
        try { return new ActiveXObject("Microsoft.XMLHTTP"); }
        catch (e) { }
        //Microsoft.XMLHTTP points to Msxml2.XMLHTTP and is redundant
        throw new Error("This browser does not support XMLHttpRequest.");
    };

var lastFrom;

function getRoutes(from) {
    var xmlHttp = new XMLHttpRequest();

    xmlHttp.onreadystatechange = function () {
        if (xmlHttp.readyState == 4) {
            var buffer = xmlHttp.responseText;    
            document.getElementById("gh_report").innerHTML = buffer;
        }
    }

    if ((lastFrom == from)) {      
        return;
    }

    lastFrom = from;

    var gif = "<div><img alt=''src='../images/spinner10.gif' /></div>";
    document.getElementById("gh_report").innerHTML = gif;
    xmlHttp.open("GET", "ghquery.cshtml?city=" + from, true);
    xmlHttp.send(null);
}

function getGuestHouses() {
    var dropdownFrom = document.getElementById("DropDownListCity");
    var myindexFrom = dropdownFrom.selectedIndex;
    var SelValueFrom = dropdownFrom.options[myindexFrom].value;
    getRoutes(SelValueFrom);
}       